package cc.sunni.test.serivce.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

/**
 * @author jiangli
 * @since 2021/3/18 16:18
 */
public class FilterUtils {

    public static <T> List<T> filter(List<T> list, Predicate<T> p) {
        List<T> result = new ArrayList<>();
        for (T t : list) {
            if (p.test(t)) {
                result.add(t);
            }
        }
        return result;
    }
}
